﻿
$(function () {

  // order by dropdown
  var actionButton = $('.top-menu .drop-downs input[type=submit]').eq(0).hide();
  $('.top-menu .drop-downs select').change(function () {
    actionButton.click();
  });

  // tree
  var $tree = $('.tree');
  $tree.css('visibility', 'visible');
  $tree.find('.v-panels').panels(true, '.scroll');

  $('.tree ul.scroll')
    .filter(function () {
      var $this = $(this);
      return ($this.innerHeight() == parseInt($this.css('max-height'))) && ($this[0].clientHeight < $this[0].scrollHeight);
    })
  .each(function (index, element) {
    var $this = $(this);
    var $cur = $this.find('> li.active').eq(0);
    if ($cur.length) {
      var pos = $cur.position();
      $this.scrollTop(pos.top);
    }
  });


});